from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet

from goods.models import SPUSpecification, SPU
from meiduo_admin.serializer.specs import SPUSpecificationSerialzier, SPUSerializer
from meiduo_admin.utils import UserPageNum


# 查询获取规格表列表数据
class SpecView(ModelViewSet):

    # 指定分页器
    pagination_class = UserPageNum
    # 指定序列化器
    serializer_class =SPUSpecificationSerialzier
    #指定查询集
    queryset = SPUSpecification.objects.all()

    # 获取spu的商品信息
    def simple(self,request):
        spec =SPU.objects.all()
        ser = SPUSerializer(spec,many=True)
        return Response(ser.data)



